package io;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class TestNote {
    public static void main(String[] args) throws IOException {
        Scanner scan=new Scanner(System.in);
        File file=new File("note.txt");
        file.createNewFile();
            FileOutputStream fos=new FileOutputStream("note.txt");
        System.out.println("请输入内容，单独输入exit退出");
        while (true){
            String line=scan.nextLine();
            if ("exit".equals(line)){
                break;
            }
            fos.write(line.getBytes(StandardCharsets.UTF_8));
        }
        System.out.println("结束了");
        fos.close();

        /*
        Scanner scan=new Scanner(System.in);
        File file=new File("note.txt");
        if (file.exists()){
            System.out.println("文件存在");
        }else{
            file.createNewFile();
            System.out.println("文件已创建");
        }
        FileOutputStream fos=new FileOutputStream("note.txt");
        System.out.println("请输入内容,单独输入exit退出");
        while (true){
            String line=scan.nextLine();
            if ("exit".equals(line)){
                break;
            }
            fos.write(line.getBytes(StandardCharsets.UTF_8));
        }
        System.out.println("结束了");
        fos.close();

         */

    }
}
